﻿Imports Microsoft.Office
Public Class Outlook

  Private Shared _instance As Outlook

  Private _config As Configuration = Configuration.GetObject
  Private _app As Microsoft.Office.Interop.Outlook.Application
  Private _ns As Interop.Outlook.NameSpace
  Private _fdMail As Interop.Outlook.MAPIFolder


  Private Sub New()
    _app = New Microsoft.Office.Interop.Outlook.Application
    _ns = _app.GetNamespace("MAPI")
    _fdMail = _ns.GetDefaultFolder(Interop.Outlook.OlDefaultFolders.olFolderOutbox)
  End Sub

  Public Shared ReadOnly Property GetObject() As Outlook
    Get
      If _instance Is Nothing Then
        _instance = New Outlook()
      End If
      Return _instance
    End Get
  End Property

  Public ReadOnly Property NewMail() As Interop.Outlook.MailItem
    Get
      Return _fdMail.Items.Add(Interop.Outlook.OlItemType.olMailItem)
    End Get
  End Property

End Class
